
{% extends 'layout/basic.html' %}
{% load static %}
{% block title %}用户短信登录{% endblock %}

{% block css %}
    <link rel="stylesheet" href="{% static 'css/account.css' %}">
<style>
    .error-msg{
        color: red;
        position: absolute;
        font-size: 13px;
    }
    </style>
{% endblock %}



{% block content %}
     <div class="account">
        <div class="title">用户短信登录</div>
            <form id="smsForm"  method="POST" novalidate>
            {% csrf_token %}
                {% for field in form %}
                    {% if field.name == 'code' %}
                        <div class="form-group">
                             <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                                 <div class="row">
                                     <div class="col-xs-7">
                                         {{ field }}
                                         <span class="error-msg">{{ field.errors.0 }}</span>
                                     </div>
                                     <div class="col-xs-5">
                                         <img src="{% url 'image_code' %}" id="imageCode" title="点击更换图片">
                                     </div>
                                 </div>
                        </div>
                    {% else %}
                        <div class="form-group">
                         <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                         {{ field }}
                        <span class="error-msg">{{ field.errors.0 }}</span>
                        </div>
                    {% endif %}
                {% endfor %}
            <div class="row">
                 <div class="col-xs-3">
                <input  type="submit" class="btn btn-primary" value="登录">
            </div>
                <div class="" style="float: right"><a href="{% url 'login_sms' %}">短信验证码登录？</a></div>
            </div>


    </form>
    </div>
{% endblock %}



{% block js %}
    <script>
        $('#imageCode').click(function () {
            var lodCode = $(this).attr('src').replace('?',''); // 用？重新加载src，并删除？，一面每次加一个？占用资源
            $(this).attr('src',lodCode+'?');
        })

    </script>
{% endblock %}